<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function selectSort(nums) {
      let len = nums.length,minIndex,tem;
      for(let i=0;i<len;i++) {
        minIndex = i;
        for(let j=i;j<len;j++) {
          if(nums[j] < nums[minIndex]) {
            minIndex = j;
          }
        }
        tem = nums[i];
        nums[i] = nums[minIndex];
        nums[minIndex] = tem;
      }
      return nums;
    }
    console.log(selectSort([1,2,5,4,6,10,8]));
  </script>
</body>
</html>